/**
 * Init creates the Window.require method that will dynamically load javascript
 * source files, and insert them in to the DOM. It also creates the initial 
 * CanvasMapper object, and attaches it to the Canvas element.
 * @author mcamden
 */

(function () {
	// Set window as self
	var self = this;
	
	/**
	 * Appends the value of source to the DOM head. Source can be a string or
	 * an array of values.
	 * 
	 * @param {Mixed} source
	 * @return {Void}
	 */
	self.require = function (source) {
		if(typeof(source) == "undefined") {
			return;
		}
		if(source instanceof Array) {
			for(i in source) {
				self.require(source[i]);
			}
		}
		else if(typeof(source) == "string") {
			var src = document.createElement("script"), head = document.getElementsByTagName("head");
				head = head[0];
				src.type = "text/javascript";
				src.src = source;
			
			head.appendChild(src);
			// Clean up
			delete(src);
			delete(head);
			delete(source);
		}
		// Should always return something -- I guess
		return true;
	};
})();

(function () {
	// Support filez
	require("Events.js");
	// Call canvas mapper
	require("CanvasMapper.js");
	
})();